#pragma once
#pragma warning(disable:4996)       // disable checked iterator errors http://msdn.microsoft.com/en-us/library/aa985965(VS.80).aspx 

//
// Copyright (C) 2011 Steve Channell steve.channell@cepheis.com
//
// This file is part of Cephei.QL, an open-source library wrapper 
// arround QuantLib http://quantlib.org/
//
// Cephei.QL is open source software: you can redistribute it and/or modify it
// under the terms of the license.  You should have received a
// copy of the license along with this program; if not, please email
// <support@cepheis.com>. The license is also available online at
// <http://cepheis.com/license.htm>.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE.  See the license for more details.
//
// Version 2.101

#include <Macros.h>
#include <CoVector.h>
#include <CoMatrix.h>
#include <CoCube.h>
#include <ValueHelpers.h>
#include <Settings.h>

#include <gen/QL/TermStructure.h>
#pragma unmanaged 
#include <ql\experimental\callablebonds\callablebondvolstructure.hpp>
#include <boost/smart_ptr/detail/spinlock.hpp>
#pragma managed 

using namespace System;
using namespace QuantLib;
using namespace Cephei;

using namespace Cephei::QL::Times;
using namespace Cephei::QL::Termstructures::Volatility;
using namespace Cephei::QL;
#define HANDLE
#define ABSTRACT
#undef STRUCT
namespace Cephei { namespace QL { namespace Experimental { namespace Callablebonds {
	//////////////////////////////////////////////////////////////////////////////////////////////
	// implementation of ICallableBondVolatilityStructure
	public ref class CCallableBondVolatilityStructure : 
            public CTermStructure,
            public Cephei::QL::Experimental::Callablebonds::ICallableBondVolatilityStructure
	{
	protected: 
		boost::shared_ptr<QuantLib::CallableBondVolatilityStructure>* _ppCallableBondVolatilityStructure;
#ifdef HANDLE
		QuantLib::Handle<QuantLib::CallableBondVolatilityStructure>* _phCallableBondVolatilityStructure;
#endif
		Object^ _CallableBondVolatilityStructureOwner;     // reference to object that manages the storage for this object
	internal:
        CCallableBondVolatilityStructure (boost::shared_ptr<QuantLib::CallableBondVolatilityStructure>& childNative, Object^ owner);
        CCallableBondVolatilityStructure (QuantLib::CallableBondVolatilityStructure& childNative, Object^ owner);
        CCallableBondVolatilityStructure (CCallableBondVolatilityStructure^ copy);
        CCallableBondVolatilityStructure (System::Type^ t);
#ifdef STRUCT
        CCallableBondVolatilityStructure (QuantLib::CallableBondVolatilityStructure childNative);
#endif       
#ifdef HANDLE
		CCallableBondVolatilityStructure (QuantLib::Handle<QuantLib::CallableBondVolatilityStructure>& childNative, Object^ owner);
		CCallableBondVolatilityStructure (QuantLib::Handle<QuantLib::CallableBondVolatilityStructure> childNative);
#endif
		virtual ~CCallableBondVolatilityStructure ();
		!CCallableBondVolatilityStructure ();

	internal:
		QuantLib::CallableBondVolatilityStructure& GetReference ();
		boost::shared_ptr<QuantLib::CallableBondVolatilityStructure>& GetShared ();
		QuantLib::CallableBondVolatilityStructure* GetPointer ();
        void SetCallableBondVolatilityStructure (boost::shared_ptr<QuantLib::CallableBondVolatilityStructure> native)
        {
            if (_ppCallableBondVolatilityStructure != NULL)
                delete _ppCallableBondVolatilityStructure;
            _ppCallableBondVolatilityStructure = new boost::shared_ptr<QuantLib::CallableBondVolatilityStructure> (native);
            SetTermStructure (boost::dynamic_pointer_cast<QuantLib::TermStructure> (*_ppCallableBondVolatilityStructure));
        }
#ifdef HANDLE
		QuantLib::Handle<QuantLib::CallableBondVolatilityStructure>& GetHandle ();
#endif
		virtual bool HasNative () override;
    public:
		virtual Double BlackVariance (Cephei::QL::Times::IPeriod^ optionTenor, Cephei::QL::Times::IPeriod^ bondTenor, Double strike, Microsoft::FSharp::Core::FSharpOption<Boolean>^ extrapolate) ;
		virtual Double BlackVariance (DateTime optionDate, Cephei::QL::Times::IPeriod^ bondTenor, Double strike, Microsoft::FSharp::Core::FSharpOption<Boolean>^ extrapolate) ;
		virtual Double BlackVariance (Double optionTime, Double bondLength, Double strike, Microsoft::FSharp::Core::FSharpOption<Boolean>^ extrapolate) ;
        property QL::Times::BusinessDayConventionEnum BusinessDayConvention 
        {
		    virtual QL::Times::BusinessDayConventionEnum get () ;
        }
        property Double MaxBondLength 
        {
		    virtual Double get () ;
        }
        property Cephei::QL::Times::IPeriod^ MaxBondTenor 
        {
		    virtual Cephei::QL::Times::IPeriod^ get () ;
        }
        property Double MaxStrike 
        {
		    virtual Double get () ;
        }
        property Double MinStrike 
        {
		    virtual Double get () ;
        }
		virtual DateTime OptionDateFromTenor (Cephei::QL::Times::IPeriod^ optionTenor) ;
		virtual Cephei::QL::Termstructures::Volatility::ISmileSection^ SmileSection (Cephei::QL::Times::IPeriod^ optionTenor, Cephei::QL::Times::IPeriod^ bondTenor) ;
		virtual Cephei::QL::Termstructures::Volatility::ISmileSection^ SmileSection (DateTime optionDate, Cephei::QL::Times::IPeriod^ bondTenor) ;
		virtual Double Volatility (Cephei::QL::Times::IPeriod^ optionTenor, Cephei::QL::Times::IPeriod^ bondTenor, Double strike, Microsoft::FSharp::Core::FSharpOption<Boolean>^ extrapolate) ;
		virtual Double Volatility (DateTime optionDate, Cephei::QL::Times::IPeriod^ bondTenor, Double strike, Microsoft::FSharp::Core::FSharpOption<Boolean>^ extrapolate) ;
		virtual Double Volatility (Double optionTime, Double bondLength, Double strike, Microsoft::FSharp::Core::FSharpOption<Boolean>^ extrapolate) ;
    };
	//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// Factory class
	public ref class CCallableBondVolatilityStructure_Factory : public System::MarshalByRefObject,  public ICallableBondVolatilityStructure_Factory
	{
	public:
    };
   
/*Cephei*/ } /*QL*/ } /*Experimental*/ } /*Callablebonds */}
